#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main() {
    int T;
    scanf("%d", &T);
    int t1, t2, t3, t4;
    int i = 0;
    for (i = 0; i < T; i++) {
        scanf("%d:%d %d:%d", &t1, &t2, &t3, &t4);
        if (t3 > t1) {
            if (t4 >= t2) {
                if (t3 - t1 + (t4 - t2) / 60 <= 23)
                    printf("%02dh%02dmin\n", t3 - t1 + (t4 - t2) / 60, (t4 - t2) % 60);
            }
            else {
                if (t3 - t1 + (t4 - t2) / 60 <= 23)
                    printf("%02dh%02dmin\n", t3 - t1 + (t2 - t4) / 60, (t2 - t4) % 60);
            }
        }
        else {//t1 <= t3
            if (t4 >= t2) {
                if (24 - t1 + t3 - 0 + (t4 - t2) / 60 <= 23)
                    printf("%02dh%02dmin\n", 24 - t1 + t3 - 0 + (t4 - t2) / 60, (t4 - t2) % 60);
            }
            else {
                if (24 - t1 + t3 - 0 + (t4 - t2) / 60 <= 23)
                    printf("%02dh%02dmin\n", 24 - t1 + t3 - 0 + (t2 - t4) / 60, (t2 - t4) % 60);
            }
        }
    }
    return 0;
}